function Try
{
    param
    (
        [ScriptBlock]$Command = $(Throw "The parameter -Command is required."),
        [ScriptBlock]$Catch   = { Throw $_ },
        [ScriptBlock]$Finally = {}
    )
    
    & {
        $local:ErrorActionPreference = "Stop"
        
        trap
        {
            trap
            {
                & {
                    trap { Throw $_ }
                    &$Finally
                }
                
                Throw $_
            }
            
            $_ | & { &$Catch }
        }
        
        &$Command
    }

    & {
        trap { Throw $_ }
        &$Finally
    }
}
